package b.b.c;

import android.content.Context;
import android.content.ContextWrapper;
import android.util.AttributeSet;
import android.view.InflateException;
import android.view.View;
import android.view.View.OnClickListener;
import androidx.appcompat.widget.AppCompatAutoCompleteTextView;
import androidx.appcompat.widget.AppCompatButton;
import androidx.appcompat.widget.AppCompatCheckBox;
import androidx.appcompat.widget.AppCompatRadioButton;
import androidx.appcompat.widget.AppCompatTextView;
import b.f.h;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/* compiled from: AppCompatViewInflater */
public class n {
    public static final Class<?>[] b = new Class[]{Context.class, AttributeSet.class};
    public static final int[] c = new int[]{16843375};
    public static final String[] d = new String[]{"android.widget.", "android.view.", "android.webkit."};
    public static final h<String, Constructor<? extends View>> e = new h();
    public final Object[] a = new Object[2];

    /* compiled from: AppCompatViewInflater */
    public static class a implements OnClickListener {
        public final View a;
        public final String b;
        public Method c;
        public Context d;

        public a(View view, String str) {
            this.a = view;
            this.b = str;
        }

        public void onClick(View view) {
            if (this.c == null) {
                String str;
                for (Context context = this.a.getContext(); context != null; context = context instanceof ContextWrapper ? ((ContextWrapper) context).getBaseContext() : null) {
                    try {
                        if (!context.isRestricted()) {
                            Method method = context.getClass().getMethod(this.b, new Class[]{View.class});
                            if (method != null) {
                                this.c = method;
                                this.d = context;
                            }
                        }
                    } catch (NoSuchMethodException unused) {
                    }
                }
                int id = this.a.getId();
                if (id == -1) {
                    str = "";
                } else {
                    StringBuilder g = c.b.a.a.a.g(" with id '");
                    g.append(this.a.getContext().getResources().getResourceEntryName(id));
                    g.append("'");
                    str = g.toString();
                }
                StringBuilder g2 = c.b.a.a.a.g("Could not find method ");
                g2.append(this.b);
                g2.append("(View) in a parent or ancestor Context for android:onClick attribute defined on view ");
                g2.append(this.a.getClass());
                g2.append(str);
                throw new IllegalStateException(g2.toString());
            }
            try {
                this.c.invoke(this.d, new Object[]{view});
            } catch (IllegalAccessException e) {
                throw new IllegalStateException("Could not execute non-public method for android:onClick", e);
            } catch (InvocationTargetException e2) {
                throw new IllegalStateException("Could not execute method for android:onClick", e2);
            }
        }
    }

    public AppCompatAutoCompleteTextView a(Context context, AttributeSet attributeSet) {
        return new AppCompatAutoCompleteTextView(context, attributeSet);
    }

    public AppCompatButton b(Context context, AttributeSet attributeSet) {
        return new AppCompatButton(context, attributeSet);
    }

    public AppCompatCheckBox c(Context context, AttributeSet attributeSet) {
        return new AppCompatCheckBox(context, attributeSet);
    }

    public AppCompatRadioButton d(Context context, AttributeSet attributeSet) {
        return new AppCompatRadioButton(context, attributeSet, 2130969246);
    }

    public AppCompatTextView e(Context context, AttributeSet attributeSet) {
        return new AppCompatTextView(context, attributeSet);
    }

    public View f() {
        return null;
    }

    public final View g(Context context, String str, String str2) throws ClassNotFoundException, InflateException {
        h hVar = e;
        Constructor constructor = (Constructor) hVar.getOrDefault(str, null);
        if (constructor == null) {
            if (str2 != null) {
                try {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.append(str2);
                    stringBuilder.append(str);
                    str2 = stringBuilder.toString();
                } catch (Exception unused) {
                    return null;
                }
            }
            str2 = str;
            constructor = Class.forName(str2, false, context.getClassLoader()).asSubclass(View.class).getConstructor(b);
            hVar.put(str, constructor);
        }
        constructor.setAccessible(true);
        return (View) constructor.newInstance(this.a);
    }

    public final void h(View view, String str) {
        if (view == null) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(getClass().getName());
            stringBuilder.append(" asked to inflate view for <");
            stringBuilder.append(str);
            stringBuilder.append(">, but returned null");
            throw new IllegalStateException(stringBuilder.toString());
        }
    }
}
